;
; ------------------------------------------------------------
;
;   PureBasic - ToolBar example file
;
;    (c) 2003 - Fantaisie Software
;
; ------------------------------------------------------------
;


If OpenWindow(0, 100, 200, 195, 260, "ToolBar example", #PB_Window_SystemMenu | #PB_Window_SizeGadget)

  If CreateToolBar(0, WindowID(0))
    ToolBarStandardButton(0, #PB_ToolBarIcon_New)
    ToolBarStandardButton(1, #PB_ToolBarIcon_Open)
    ToolBarStandardButton(2, #PB_ToolBarIcon_Save)
    
    ToolBarSeparator()

    ToolBarStandardButton(3, #PB_ToolBarIcon_Print)
    ToolBarToolTip(0, 3, "Print")
    
    ToolBarStandardButton(4, #PB_ToolBarIcon_Find)
    ToolBarToolTip(0, 4, "Find a document")
    
    ToolBarSeparator()
      
    ToolBarImageButton(5, LoadImage(0, "Data\CdPlayer.ico"))
  EndIf


  If CreateMenu(0, WindowID(0))
    MenuTitle("Project")
      MenuItem(0, "New")
      MenuItem(1, "Open")
      MenuItem(2, "Save")
  EndIf
  
  ;
  ; Attach our previously created ToolBar to this window
  ;
    
  DisableToolBarButton(0, 2, 1) ; Disable the button '2'
  
  ;
  ; The event loop. A ToolBar event is like a Menu event (as tools are shortcut for menu the most
  ; of the time). This is handy, as if the ToolBar buttons and the MenuItem have the same ID, then
  ; the same operation can be done on both action without any adds..
  ;
  
  Repeat
    EventID = WaitWindowEvent()

    ;Debug EventID
    ;Debug EventGadgetID()

    Select EventID
    
      Case #PB_Event_Menu
        MessageRequester("Information", "ToolBar or Menu ID: "+Str(EventMenu()), 0)
      
      Case #PB_Event_CloseWindow  ; If the user has pressed on the close button
        Quit = 1
        
    EndSelect

  Until Quit = 1
  
EndIf

End   ; All the opened windows are closed automatically by PureBasic
   